<#import "../_layout.ftl" as layout>
${Html.s("pagetitle","编辑应用")}
<@layout._layout>
    <script src="/content/ace-src-min-noconflict/ace.js"></script>
    <script src="/content/ace-src-min-noconflict/ext-language_tools.js"></script>
    <script src="/content/js/myAce.js"></script>
    <div class="head">
        <div class="title">
            编辑应用 ${Html.help("编辑应用")}
        </div>
    </div>
    <div>
        <ul class="mydetail">
            <li>
                <label>应用名</label>
                <input class="mylongtext" type="text" id="project_name" name="project_name" value="${model.project_name!}" />
            </li>
            <li>
                <label>描述</label>
                <input class="mylongtext" type="text" id="project_desc" name="project_desc" value="${model.project_desc!}" />
            </li>
            <li>
                <label>网址</label>
                <input class="mylongtext" type="text" id="url" name="url" value="${model.url!}" />
            </li>
            <li>
                <div id="tabs">
                    <ul>
                        <li><a href="#tabs-1">前端配置</a></li>
                        <li><a href="#tabs-2">后端配置</a></li>
                    </ul>
                    <div id="tabs-1">
                        <textarea id="front_metric_config" name="front_metric_config" rows="20" cols="40" style="width: 90%;"></textarea>
                        <input id="hd_front_metric_config" type="hidden" value="${model.front_metric_config!?html}">
                    </div>
                    <div id="tabs-2">
                        <textarea id="back_metric_config" name="back_metric_config" rows="20" cols="40" style="width: 90%;"></textarea>
                        <input id="hd_back_metric_config" type="hidden" value="${model.back_metric_config!?html}">
                    </div>
                </div>
            </li>
            <li>
                <input type="button" class="btn1" style="" value="保存" onclick="return save()" />
            </li>
        </ul>
    </div>
    <script type="text/javascript">
        var front_metric_config_script;
        var back_metric_config_script;
        $( function() {
            $( "#tabs").tabs();
           front_metric_config_script=bindAce("front_metric_config",$("#hd_front_metric_config").val());
            bindAppAutocompletion(front_metric_config_script);
            back_metric_config_script=bindAce("back_metric_config",$("#hd_back_metric_config").val());
            bindAppAutocompletion(back_metric_config_script);
        } );
        function save()
        {
            $.post("/project/save",
                {
                    "id": ${id!"0"},
                    "project_name": $("#project_name").val(),
                    "project_desc": $("#project_desc").val(),
                    "front_metric_config": front_metric_config_script.getValue(),
                    "back_metric_config":back_metric_config_script.getValue(),
                    "url":$('#url').val()
                },
                function (data) {
                    if (data.code < 0) {
                        alert(data.message);
                    } else {
                        window.location = '/project/index';
                    }
                }, "json");
        }

    </script>
</@layout._layout>